import java.util.ArrayList;

public class OrderForm {
    private String name;
    private ArrayList<String> dish = new ArrayList<>();
    private ArrayList<Integer> dishNum = new ArrayList<>();
    private ArrayList<Double> dishPrices = new ArrayList<>();
    private int time;
    private String address;
    private boolean states = true;
    double freight = 5.0;
    double sumPrices = 0;

    public boolean isNull(){
        if (this.name == null){
            return true;
        } else {
            return false;
        }
    }

    public void setDish(int menuIndex, int foodNum){
        dish.add(FoodMenu.food[menuIndex]);
        dishNum.add(foodNum);
        dishPrices.add(FoodMenu.price[menuIndex] * foodNum);
    }

    public void setName(String name, int time, String address){
        this.name = name;
        this.time = time;
        this.address = address;
        this.states = true;
        for (double dishPrice: dishPrices
             ) {
            sumPrices += dishPrice;
        }
        if (sumPrices >= 50){
            freight = 0.0;
        }
        sumPrices += freight;
    }

    public int getTime(){
        return time;
    }

    public double getFreight(){
        return freight;
    }

    public double getSumPrices(){
        return sumPrices;
    }

    public double getDishPrices(int dishIndex) {
        return dishPrices.get(dishIndex);
    }

    public void show(){
        System.out.println(name);
        System.out.println(time);
        System.out.println(address);
    }
}
